package com.ruoyi.manage.controller;

import com.github.pagehelper.PageInfo;
import com.ruoyi.common.core.cg.pojo.User;
import com.ruoyi.common.core.cg.result.Queryparam;
import com.ruoyi.common.core.cg.result.Result;
import com.ruoyi.manage.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 马景昌
 * @create 2025/03/05
 * @description
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;
    @GetMapping("/pageshow")
    public Result page(User user){
        Result pageshow = userService.pageshow(user);
        return pageshow;
    }
    @GetMapping(value = "/{userId}")
    public Result hx(@PathVariable("userId") Integer userId){
        Result result = userService.hx(userId);
        return result;
    }
    @PutMapping("/update")
    public Result update(@RequestBody User user){
        Result result = userService.update(user);
        return result;
    }
    @DeleteMapping("/{user_id}")
    public Result delete(@PathVariable("user_id") Integer userId){
        Result result = userService.delete(userId);
        return result;
    }
    @PostMapping
    public Result add(@RequestBody User user){
        Result result = userService.add(user);
        return result;
    }

    @RequestMapping("/routerSelect")
    public PageInfo<User> routerSelect(@RequestBody Queryparam queryparam){
        PageInfo<User> pageInfo = userService.routerSelect(queryparam);
        return pageInfo;
    }
}
